﻿using System;
using System.Data.Services;
using System.ServiceModel;
using ADO_Data_Service;

namespace Host
{
    class Program
    {
        static void Main(string[] args)
        {
            DataServiceHost host = null;
            DataServiceHost host2 = null;
            const string sURI = "http://localhost:37052/ExampleDataService.svc";
            const string sURI2 = "http://localhost:37052/ExampleDataService2.svc";

            try
            {
                var baseAddress = new Uri(sURI);
                var baseAddress2 = new Uri(sURI2);

                host = new DataServiceHost(typeof(ExampleDataService), new Uri[] { baseAddress });
                host.Open();

                host2 = new DataServiceHost(typeof(ExampleDataService2), new Uri[] { baseAddress2 });
                host2.Open();

                Console.WriteLine(string.Format("Host running - {0}", sURI));
                Console.WriteLine(string.Format("Host running - {0}", sURI2));
                Console.WriteLine("Press any key to shut down service...");
                Console.ReadKey();

                host.Close();
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("Error: {0}", ce.Message);
                if (host != null) host.Abort();
                if (host2 != null) host2.Abort();
            }
        }
    }
}
